//
//  OTDR_SocketServer.h
//  OTDR
//
//  Created by Liu on 2024/5/23.
//

#import <Foundation/Foundation.h>
#import <GCDAsyncSocket.h>

NS_ASSUME_NONNULL_BEGIN
@protocol SocketSourceDataDelegate <NSObject>
- (void)didReadData:(NSData *)data withTag:(long)tag;
@end

@interface OTDR_SocketServer : NSObject<GCDAsyncSocketDelegate>
{
    GCDAsyncSocket *_asyncSocket;
    int reConnectCount;
    
    dispatch_source_t _connectTimer;
    dispatch_queue_t _connectQueue;
    BOOL connectInterrupt;
}


@property (nonatomic, weak) id <SocketSourceDataDelegate> delegate;

+ (instancetype)sharedInstance;
/** 是否连接 */
- (BOOL)isFCDisConnect;


//连接socket 地址 端口号
- (void)connectWithHost:(NSString *)hostName port:(int)port;

- (void)writeToFCTCPWithData:(NSData *)data;
/**
 * 关闭HGFCTCPSocketServe
 */
-(void)stopConnect;
/**是否连接成功**/
@property(nonatomic ,copy)void (^connectIsSuccessBlock)(BOOL isConnected);

-(void)DeallocAll;

@end

NS_ASSUME_NONNULL_END
